<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title>管理系统</title>

    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/font-awesome/4.5.0/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/fonts.googleapis.com.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace.min.css}" class="ace-main-stylesheet" id="main-ace-style"/>
    <link rel="stylesheet" th:href="@{/css/ace-part2.min.css}" class="ace-main-stylesheet"/>
    <link rel="stylesheet" th:href="@{/css/ace-skins.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace-rtl.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace-ie.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/dataTables.bootstrap4.min.css}"/>
    <script th:src="@{/js/ace-extra.min.js}"></script>
    <script th:src="@{/js/html5shiv.min.js}"></script>
    <script th:src="@{/js/respond.min.js}"></script>
</head>

<body class="no-skin">
<!--头导航栏-->
<div th:replace="common/bar::#navbar"></div>
<div class="main-container ace-save-state" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.loadState('main-container')
        } catch (e) {
        }
    </script>
    <!-- 侧导航栏 -->
    <div th:replace="common/bar::#sidebar"></div>

    <div class="main-content">
        <div class="main-content-inner">
            <div class="breadcrumbs ace-save-state" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i>
                        <a href="#">sys</a>
                    </li>
                    <li class="active">index</li>
                </ul><!-- /.breadcrumb -->
            </div>
            <div th:replace="common/modal::#msg_modal"></div>
            <div class="page-content">
                <div class="table-responsive">
                    <table class="table table-bordered table-hover text-nowrap" id="dateTable"
                           cellspacing="0">
                        <thead>
                        <tr>
                            <th>报告id</th>
                            <th>报告编号</th>
                            <th>检测日期</th>
                            <th>姓名/单位</th>
                            <th>创建时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <div class="footer">
        <div class="footer-inner">
            <div class="footer-content">
                <span class="bigger-120">
                    <span class="blue bolder">公里派</span>
                    管理系统 &copy; 2020
                </span>
            </div>
        </div>
    </div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->
<script th:src="@{/js/jquery-2.1.4.min.js}"></script>
<script th:src="@{/js/jquery-1.11.3.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/ace-elements.min.js}"></script>
<script th:src="@{/js/ace.min.js}"></script>
<script th:src="@{/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/js/dataTables.bootstrap4.min.js}"></script>
<!--公共js ， 有装载dateTable的公共js-->
<script th:src="@{/custom/common.js}"></script>
</body>
<script>
    var columns = [
        {"data": "reportId", visible: false},
        {"data": "jcbgbh"},
        {"data": "jxjcrq"},
        {"data": "xmdw"},
        {
            "data": "createTime",
            render: function (data, type, full) {
                return new Date(data).toLocaleDateString();
            }
        },
        {
            "data": "status",
            render: function (data, type, full) {
                return getStatusName(data,full.reportId);
            }
        },
        {
            render: function (data, type, full) {
                var temp = "<button onclick='report_view(" + full.reportId + ");'  class='btn btn-info btn-sm'> 查看</button>" +
                    "<button onclick='report_remove(" + full.reportId + ");'  class='btn btn-danger btn-sm'> 删除</button>";
                if(full.status == 3 || full.status == 5){
                    temp += "<button onclick='report_resubmit(" + full.reportId + ");'  class='btn btn-success btn-sm'>提交</button>";
                }
                return temp;
            },
        }
    ];
    $(function () {
        load_table("/report/getList", columns);
    });

    function report_view(reportId) {
        window.location.href = "/report/submit-view?reportId=" + reportId;
    }

    function report_remove(reportId) {
        if (confirm("确认删除？")) {
            $.ajax({
                type: "post",
                url: "/report/remove?reportId=" + reportId,
                success: function (res) {
                    $("#dateTable").DataTable().ajax.reload();
                }
            })
        }
    }
    function report_resubmit(reportId) {
        if (confirm("已确认修改？")) {
            $.ajax({
                type: "post",
                url: "/report/resubmit?reportId=" + reportId,
                success: function (res) {
                    $("#dateTable").DataTable().ajax.reload();
                }
            })
        }
    }
</script>
</html>
